﻿//-----------------------------------------------------------------------
// <copyright file="SendPrivateMessageViewModel.cs" company="AFS">
// Copyright (c) AFS. All rights reserved.
//
//    This file is part of Chatbox.
//
//    Chatbox is free software: you can redistribute it and/or modify
//    it under the terms of the GNU Lesser General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    any later version.
//
//    Chatbox is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//    GNU Lesser General Public License for more details.
//
//    You should have received a copy of the GNU Lesser General Public License
//    along with Chatbox. If not, see http://www.gnu.org/copyleft/lesser.html
// </copyright>
//----------------------------------------------------------------------- 

namespace ChatBox.UI.Windows.SendPrivateMessage
{
    using System.Windows.Input;

    using ChatBox.DomainObjects.XmlFeedObjects;
    using ChatBox.Interfaces;
    using ChatBox.UI.ViewModels;

    using Commands;

    /// <summary>
    /// View model for the "Send private message window"
    /// </summary>
    public class SendPrivateMessageViewModel : WindowViewModel
    {
        #region data

        /// <summary>
        /// the command to send the message
        /// </summary>
        private readonly ICommand sendPrivateMessageCommand;

        /// <summary>
        /// the command to close the window
        /// </summary>
        private readonly ICommand windowCloseCommand;

        /// <summary>
        /// The message to send
        /// </summary>
        private string messageText;

        /// <summary>
        /// The winbdow title text
        /// </summary>
        private string titleText;

        /// <summary>
        /// The content for the label
        /// </summary>
        private object labelContent;

        /// <summary>
        /// Is the spelling checker enabled
        /// </summary>
        private bool spellCheckIsEnabled;

        #endregion

        /// <summary>
        /// Initializes a new instance of the SendPrivateMessageViewModel class
        /// </summary>
        /// <param name="sendPrivateMessageCommand">the command to send the message</param>
        /// <param name="windowCloseCommand">the command to close the window</param>
        public SendPrivateMessageViewModel(SendPrivateMessageCommand sendPrivateMessageCommand, WindowCloseCommand windowCloseCommand)
        {
            this.sendPrivateMessageCommand = sendPrivateMessageCommand;
            this.windowCloseCommand = windowCloseCommand;
        }

        #region dependency peoperties

        /// <summary>
        /// Gets or sets the message to send
        /// </summary>
        public string MessageText
        {
            get
            {
                return this.messageText;
            }

            set
            {
                if (this.messageText != value)
                {
                    this.messageText = value;
                    OnPropertyChanged("MessageText");
                }                
            }
        }

        /// <summary>
        /// Gets or sets the window title text
        /// </summary>
        public string TitleText
        {
            get
            {
                return this.titleText;
            }

            set
            {
                if (this.titleText != value)
                {
                    this.titleText = value;
                    OnPropertyChanged("TitleText");
                }
            }
        }

        /// <summary>
        /// Gets or sets the label content
        /// </summary>
        public object LabelContent
        {
            get
            {
                return this.labelContent;
            }

            set
            {
                if (this.labelContent != value)
                {
                    this.labelContent = value;
                    OnPropertyChanged("LabelContent");
                }
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether the built-in spelling checker is enabled
        /// </summary>
        public bool SpellCheckIsEnabled
        {
            get
            {
                return this.spellCheckIsEnabled;
            }

            set
            {
                if (this.spellCheckIsEnabled != value)
                {
                    this.spellCheckIsEnabled = value;
                    OnPropertyChanged("SpellCheckIsEnabled");
                }
            }
        }

        #endregion

        #region properties

        /// <summary>
        /// Gets or sets the person that the message will be sent to
        /// </summary>
        public Link MessageRecipient { get; set; }

        /// <summary>
        /// Gets or sets the mechanism for sending the message
        /// </summary>
        public IChatMessageSend MessageSender { get; set; }

        /// <summary>
        /// Gets the command to send the message
        /// </summary>
        public ICommand SendPrivateMessageCommand
        {
            get { return this.sendPrivateMessageCommand; }
        }

        /// <summary>
        /// Gets the command to close the window
        /// </summary>
        public ICommand WindowCloseCommand
        {
            get { return this.windowCloseCommand; }
        }

        /// <summary>
        /// Gets or sets the command to tell the application about operations completed 
        /// </summary>
        public ICommand OperationCompletedCommand { get; set; }

        #endregion
    }
}
